<template>
	<div style="background: #f5f5f5;padding: 20px;">
		<wasteSelfExamineEntDetail></wasteSelfExamineEntDetail>
	</div>
</template>

<script>
	import wasteSelfExamineEntDetail from '@/components/waste/selfExamineEntDetail'
	let that;
	export default {
		components: {
			wasteSelfExamineEntDetail
		},
		data() {
			return {
				params: {
					facilitatorId: '',
					ticketId: '',
					subjectId: ''
				},
				entId: '',
				entName: '',
				currentScore: 0,
				list: [],
				loading: false,
				info: null,
				imgDialogVisible: false,
				dialogImageUrl: '',
				currentId: '',
				subejctId: ''
			}
		},
		created: function() {},
		mounted: function() {
			that = this
			that.params.facilitatorId = that.getQueryString("facilitatorId")
			that.params.ticketId = that.$store.state.token
			that.params.subjectId = that.getQueryString("subjectId")
			//that.getFacilitatorCustomerDetailInfo()
		},
		methods: {
			getFacilitatorCustomerDetailInfo() {
				that.ajax({
					url: '/areaSubject/getFacilitatorCustomerDetailInfo?ticketId=' + that.params.ticketId,
					data: {
						facilitatorId: that.params.facilitatorId,
						subjectId: that.params.subjectId,
						ticketId: that.params.ticketId,
					},
					//contentType: 'application/json',
					method: 'POST',
					success: function(result) {
						if (result.data) that.params.entId = result.data.entId
						that.getSubmitEntSelfListByEntId();
					},
				})
			},

			viewImg: function(val) {
				var vm = this;
				vm.dialogImageUrl = val;
				vm.imgDialogVisible = true;
			},

			getSubmitEntSelfListByEntId: function() {
				var _this = this;
				that.ajax({
					url: '/selfExamine/getSubmitEntSelfListByEntId.htm?ticketId=' + that.params.ticketId,
					data: {
						entId: _this.params.entId,
						isSubmit: 1,
						subejctId: _this.params.subjectId
					},
					dataType: 'json',
					success: function(result) {
						console.log(result);
						if (result.status == 1 && result.data) {
							_this.list = result.data;
							var item = result.data[0]
							_this.getSubmitEntSelfExamineById(item.id);
							_this.entName = item.entName;
							_this.currentScore = item.afterRectifyScore > 0 ? item.afterRectifyScore : item
								.beforeRectifyScore;
						}
					}
				})
			},
			getSubmitEntSelfExamineById: function(id) {
				var _this = this;
				if (id == _this.currentId) return;

				_this.currentId = id;
				_this.loading = true;
				that.ajax({
					url: '/selfExamine/getSubmitEntSelfExamineById',
					data: {
						id: _this.currentId
					},
					success: function(result) {
						if (result.status == 1 && result.data) {
							result.data.createTime = result.data.createTime.substring(0, 10);
							result.data.list.forEach(function(t) {
								t.questions.forEach(function(obj) {
									for (var i in obj.imgList) {
										obj.imgList[i] = IMGURL + '&fileID=' + obj
											.imgList[i]
									}
								})
							});
							_this.info = result.data;
							_this.loading = false;
						}
					}
				})
			}
		}
	}
</script>

<style>
	.main-container {
		position: relative;
		display: flex;
		height: 960px;
	}

	.examine-list {
		position: absolute;
		width: 40%;
		padding: 0 30px;
		background: #FFFFFF;
		border: 1px solid #EBEEF5;
		border-radius: 10px;
	}

	.examine-list .ent-name {
		height: 75px;
		line-height: 75px;
		border-bottom: 1px solid #EBEEF5;
		font-size: 24px;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #656565;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.examine-list .ent-info {
		display: flex;
		margin-bottom: -10px;
		line-height: 34px;
		font-size: 14px;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #777777;
	}

	.ent-info .ent-info-item {}

	.left {
		float: left;
	}

	.right {
		float: right;
	}

	.clear {
		clear: both;
	}

	.examine-item {
		padding: 14px 0;
		font-size: 14px;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #777777;
		border-bottom: 1px dashed #EBEEF5;
		cursor: pointer;
	}

	.examine-item:last-child {
		border-bottom: 0;
	}

	.examine-item .date {
		margin-right: 10px;
	}

	.examine-item .score {
		margin-right: 10px;
	}

	.examine-item .tag {
		font-size: 16px;
		font-family: Source Han Sans CN;
		font-weight: 400;
	}

	.tag.BLUE {
		color: #1D9DE1;
	}

	.tag.YELLOW {
		color: #FF5C00;
	}

	.tag.RED {
		color: #FC2D51;
	}

	.pdf-file {
		position: absolute;
		top: 0;
		left: calc(38% + 100px);
		right: 0;
		height: 930px;
		padding: 0 30px 30px;
		background: #E7E7E7;
		border: 1px solid #EBEEF5;
		border-radius: 10px;
		overflow-y: auto;
	}

	.ent-info .tag {
		font-size: 14px !important;
		margin-right: 10px;
	}

	.title {
		height: 75px;
		text-align: center;
		line-height: 75px;
		font-size: 24px;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #656565;
	}

	.sub-title {
		line-height: 5px;
		text-align: center;
		font-size: 24px;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #656565;
	}

	.check-time {
		line-height: 26px;
	}

	.examine-title {
		margin-top: 10px;
		font-size: 16px;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #656565;
		font-weight: bold;
	}

	.question-title {
		margin-left: 15px;
	}

	.option-container {
		margin-left: 36px;
	}

	.img-list {
		font-size: 0;
		margin-left: 37px;
	}

	.img-item {
		display: inline-block;
		width: 100px;
		height: 100px;
		margin: 5px 5px 0 0;
		cursor: pointer;
	}

	.img-item img {
		width: 100%;
		height: 100%;
	}
</style>
